package com.bluefox.base.jpa.service;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.util.Optional;

public interface QueryByExampleExecutorService <T>{


    <S extends T> Optional<S> findOne(Example<S> example);

    <S extends T> Iterable<S> findAll(Example<S> example);


    <S extends T> Iterable<S> findAll(Example<S> example, Sort sort);


    <S extends T> Page<S> findAll(Example<S> example, Pageable pageable);

    /**
     * 返回给定条件数据的数量
     * @param example<S> example
     * @return long
     * @param <S>
     */
    <S extends T> long count(Example<S> example);

    /**
     * 检查数据存储中是否包含给定条件的数据
     * @return boolean
     */
    <S extends T> boolean exists(Example<S> example);
}
